package com.psytech.app.task.tasks_mds.webservice;

import taskmanager.psytech.com.taskmanagerservice._2.BusinessFault;
import taskmanager.psytech.com.taskmanagerservice._2.BusinessFault_Exception;
import taskmanager.psytech.com.taskmanagerservice._2.Comment;
import taskmanager.psytech.com.taskmanagerservice._2.CommentList;
import taskmanager.psytech.com.taskmanagerservice._2.ObjectFactory;
import taskmanager.psytech.com.taskmanagerservice._2.Task;
import taskmanager.psytech.com.taskmanagerservice._2.TaskList;
import taskmanager.psytech.com.taskmanagerservice._2.TaskMasterDataService;
import taskmanager.psytech.com.taskmanagerservice._2.TechnicalFault;
import taskmanager.psytech.com.taskmanagerservice._2.TechnicalFault_Exception;
import taskmanager.psytech.com.taskmanagerservice._2.Todo;
import taskmanager.psytech.com.taskmanagerservice._2.UserUidList;

import com.psytech.app.task.tasks_mds.service.ServiceLocator.ShortCut;
import com.psytech.app.task.tasks_mds.service.exception.BusinessException;
import com.psytech.app.task.tasks_mds.service.exception.TechnicalException;

public class TaskMasterDataServiceWebImpl implements TaskMasterDataService, ShortCut {

	private static final ObjectFactory FACTORY = new ObjectFactory();

	private static final String BUSSINESSFAULT_DEFAULT_MESSAGE = "";

	private static final String TECHNICALFAULT_DEFAULT_MESSAGE = "";

	@Override
	public Task assignTaskToUsers(final Todo todo) throws BusinessFault_Exception, TechnicalFault_Exception {
		try {
			return SL.getInstance().getTaskMasterDataService().assignUsersToTask(todo);
		} catch (final BusinessException businessException) {
			final BusinessFault businessFault = FACTORY.createBusinessFault();
			businessFault.setMessage(businessException.getMessage());
			businessFault.setCode(businessException.getCode());
			throw new BusinessFault_Exception(BUSSINESSFAULT_DEFAULT_MESSAGE, businessFault);
		} catch (final TechnicalException technicalException) {
			final TechnicalFault technicalFault = FACTORY.createTechnicalFault();
			technicalFault.setMessage(technicalException.getMessage());
			technicalFault.setCode(technicalException.getCode());
			throw new TechnicalFault_Exception(TECHNICALFAULT_DEFAULT_MESSAGE, technicalFault);
		}
	}

	@Override
	public Task completeTask(final Task task) throws BusinessFault_Exception, TechnicalFault_Exception {
		try {
			return SL.getInstance().getTaskMasterDataService().completeTask(task);
		} catch (final BusinessException businessException) {
			final BusinessFault businessFault = FACTORY.createBusinessFault();
			businessFault.setMessage(businessException.getMessage());
			businessFault.setCode(businessException.getCode());
			throw new BusinessFault_Exception(BUSSINESSFAULT_DEFAULT_MESSAGE, businessFault);
		} catch (final TechnicalException technicalException) {
			final TechnicalFault technicalFault = FACTORY.createTechnicalFault();
			technicalFault.setMessage(technicalException.getMessage());
			technicalFault.setCode(technicalException.getCode());
			throw new TechnicalFault_Exception(TECHNICALFAULT_DEFAULT_MESSAGE, technicalFault);
		}
	}

	@Override
	public Comment createComment(final Comment comment) throws BusinessFault_Exception, TechnicalFault_Exception {
		try {
			return SL.getInstance().getTaskMasterDataService().createComment(comment);
		} catch (final BusinessException businessException) {
			final BusinessFault businessFault = FACTORY.createBusinessFault();
			businessFault.setMessage(businessException.getMessage());
			businessFault.setCode(businessException.getCode());
			throw new BusinessFault_Exception(BUSSINESSFAULT_DEFAULT_MESSAGE, businessFault);
		} catch (final TechnicalException technicalException) {
			final TechnicalFault technicalFault = FACTORY.createTechnicalFault();
			technicalFault.setMessage(technicalException.getMessage());
			technicalFault.setCode(technicalException.getCode());
			throw new TechnicalFault_Exception(TECHNICALFAULT_DEFAULT_MESSAGE, technicalFault);
		}
	}

	@Override
	public Task createTask(final Task task) throws BusinessFault_Exception, TechnicalFault_Exception {
		try {
			return SL.getInstance().getTaskMasterDataService().createTask(task);
		} catch (final BusinessException businessException) {
			final BusinessFault businessFault = FACTORY.createBusinessFault();
			businessFault.setMessage(businessException.getMessage());
			businessFault.setCode(businessException.getCode());
			throw new BusinessFault_Exception(BUSSINESSFAULT_DEFAULT_MESSAGE, businessFault);
		} catch (final TechnicalException technicalException) {
			final TechnicalFault technicalFault = FACTORY.createTechnicalFault();
			technicalFault.setMessage(technicalException.getMessage());
			technicalFault.setCode(technicalException.getCode());
			throw new TechnicalFault_Exception(TECHNICALFAULT_DEFAULT_MESSAGE, technicalFault);
		}
	}

	@Override
	public void deleteComment(final Comment comment) throws BusinessFault_Exception, TechnicalFault_Exception {
		try {
			SL.getInstance().getTaskMasterDataService().deleteComment(comment);
		} catch (final BusinessException businessException) {
			final BusinessFault businessFault = FACTORY.createBusinessFault();
			businessFault.setMessage(businessException.getMessage());
			businessFault.setCode(businessException.getCode());
			throw new BusinessFault_Exception(BUSSINESSFAULT_DEFAULT_MESSAGE, businessFault);
		} catch (final TechnicalException technicalException) {
			final TechnicalFault technicalFault = FACTORY.createTechnicalFault();
			technicalFault.setMessage(technicalException.getMessage());
			technicalFault.setCode(technicalException.getCode());
			throw new TechnicalFault_Exception(TECHNICALFAULT_DEFAULT_MESSAGE, technicalFault);
		}
	}

	@Override
	public void deleteTask(final Task task) throws BusinessFault_Exception, TechnicalFault_Exception {
		try {
			SL.getInstance().getTaskMasterDataService().deleteTask(task);
		} catch (final BusinessException businessException) {
			final BusinessFault businessFault = FACTORY.createBusinessFault();
			businessFault.setMessage(businessException.getMessage());
			businessFault.setCode(businessException.getCode());
			throw new BusinessFault_Exception(BUSSINESSFAULT_DEFAULT_MESSAGE, businessFault);
		} catch (final TechnicalException technicalException) {
			final TechnicalFault technicalFault = FACTORY.createTechnicalFault();
			technicalFault.setMessage(technicalException.getMessage());
			technicalFault.setCode(technicalException.getCode());
			throw new TechnicalFault_Exception(TECHNICALFAULT_DEFAULT_MESSAGE, technicalFault);
		}

	}

	@Override
	public CommentList getCommentsByTask(final Task task) throws BusinessFault_Exception, TechnicalFault_Exception {
		try {
			return SL.getInstance().getTaskMasterDataService().getCommentsByTask(task);
		} catch (final BusinessException businessException) {
			final BusinessFault businessFault = FACTORY.createBusinessFault();
			businessFault.setMessage(businessException.getMessage());
			businessFault.setCode(businessException.getCode());
			throw new BusinessFault_Exception(BUSSINESSFAULT_DEFAULT_MESSAGE, businessFault);
		} catch (final TechnicalException technicalException) {
			final TechnicalFault technicalFault = FACTORY.createTechnicalFault();
			technicalFault.setMessage(technicalException.getMessage());
			technicalFault.setCode(technicalException.getCode());
			throw new TechnicalFault_Exception(TECHNICALFAULT_DEFAULT_MESSAGE, technicalFault);
		}
	}

	@Override
	public Task increasePriority(final Task task) throws BusinessFault_Exception, TechnicalFault_Exception {
		try {
			return SL.getInstance().getTaskMasterDataService().increasePriority(task);
		} catch (final BusinessException businessException) {
			final BusinessFault businessFault = FACTORY.createBusinessFault();
			businessFault.setMessage(businessException.getMessage());
			businessFault.setCode(businessException.getCode());
			throw new BusinessFault_Exception(BUSSINESSFAULT_DEFAULT_MESSAGE, businessFault);
		} catch (final TechnicalException technicalException) {
			final TechnicalFault technicalFault = FACTORY.createTechnicalFault();
			technicalFault.setMessage(technicalException.getMessage());
			technicalFault.setCode(technicalException.getCode());
			throw new TechnicalFault_Exception(TECHNICALFAULT_DEFAULT_MESSAGE, technicalFault);
		}
	}

	@Override
	public Task lowPriority(final Task task) throws BusinessFault_Exception, TechnicalFault_Exception {
		try {
			return SL.getInstance().getTaskMasterDataService().lowPriority(task);
		} catch (final BusinessException businessException) {
			final BusinessFault businessFault = FACTORY.createBusinessFault();
			businessFault.setMessage(businessException.getMessage());
			businessFault.setCode(businessException.getCode());
			throw new BusinessFault_Exception(BUSSINESSFAULT_DEFAULT_MESSAGE, businessFault);
		} catch (final TechnicalException technicalException) {
			final TechnicalFault technicalFault = FACTORY.createTechnicalFault();
			technicalFault.setMessage(technicalException.getMessage());
			technicalFault.setCode(technicalException.getCode());
			throw new TechnicalFault_Exception(TECHNICALFAULT_DEFAULT_MESSAGE, technicalFault);
		}
	}

	@Override
	public TaskList searchTask(final Task task) throws TechnicalFault_Exception {
		try {
			return SL.getInstance().getTaskMasterDataService().searchTask(task);
		} catch (final TechnicalException technicalException) {
			final TechnicalFault technicalFault = FACTORY.createTechnicalFault();
			technicalFault.setMessage(technicalException.getMessage());
			technicalFault.setCode(technicalException.getCode());
			throw new TechnicalFault_Exception(TECHNICALFAULT_DEFAULT_MESSAGE, technicalFault);
		}
	}

	@Override
	public TaskList searchTasksAssignedToUsers(final UserUidList userUidList) throws TechnicalFault_Exception {
		try {
			return SL.getInstance().getTaskMasterDataService().searchTasksAssignedToUsers(userUidList);
		} catch (final TechnicalException technicalException) {
			final TechnicalFault technicalFault = FACTORY.createTechnicalFault();
			technicalFault.setMessage(technicalException.getMessage());
			technicalFault.setCode(technicalException.getCode());
			throw new TechnicalFault_Exception(TECHNICALFAULT_DEFAULT_MESSAGE, technicalFault);
		}
	}

	@Override
	public Task startTask(final Task task) throws BusinessFault_Exception, TechnicalFault_Exception {
		try {
			return SL.getInstance().getTaskMasterDataService().startTask(task);
		} catch (final BusinessException businessException) {
			final BusinessFault businessFault = FACTORY.createBusinessFault();
			businessFault.setMessage(businessException.getMessage());
			businessFault.setCode(businessException.getCode());
			throw new BusinessFault_Exception(BUSSINESSFAULT_DEFAULT_MESSAGE, businessFault);
		} catch (final TechnicalException technicalException) {
			final TechnicalFault technicalFault = FACTORY.createTechnicalFault();
			technicalFault.setMessage(technicalException.getMessage());
			technicalFault.setCode(technicalException.getCode());
			throw new TechnicalFault_Exception(TECHNICALFAULT_DEFAULT_MESSAGE, technicalFault);
		}
	}

	@Override
	public Task suspendTask(final Task task) throws BusinessFault_Exception, TechnicalFault_Exception {
		try {
			return SL.getInstance().getTaskMasterDataService().suspendTask(task);
		} catch (final BusinessException businessException) {
			final BusinessFault businessFault = FACTORY.createBusinessFault();
			businessFault.setMessage(businessException.getMessage());
			businessFault.setCode(businessException.getCode());
			throw new BusinessFault_Exception(BUSSINESSFAULT_DEFAULT_MESSAGE, businessFault);
		} catch (final TechnicalException technicalException) {
			final TechnicalFault technicalFault = FACTORY.createTechnicalFault();
			technicalFault.setMessage(technicalException.getMessage());
			technicalFault.setCode(technicalException.getCode());
			throw new TechnicalFault_Exception(TECHNICALFAULT_DEFAULT_MESSAGE, technicalFault);
		}
	}

	@Override
	public Task unassignTaskToUsers(final Todo todo) throws BusinessFault_Exception, TechnicalFault_Exception {
		try {
			return SL.getInstance().getTaskMasterDataService().unassignedUsersToTask(todo);
		} catch (final BusinessException businessException) {
			final BusinessFault businessFault = FACTORY.createBusinessFault();
			businessFault.setMessage(businessException.getMessage());
			businessFault.setCode(businessException.getCode());
			throw new BusinessFault_Exception(BUSSINESSFAULT_DEFAULT_MESSAGE, businessFault);
		} catch (final TechnicalException technicalException) {
			final TechnicalFault technicalFault = FACTORY.createTechnicalFault();
			technicalFault.setMessage(technicalException.getMessage());
			technicalFault.setCode(technicalException.getCode());
			throw new TechnicalFault_Exception(TECHNICALFAULT_DEFAULT_MESSAGE, technicalFault);
		}
	}

	@Override
	public Task unspecifiPriority(final Task task) throws BusinessFault_Exception, TechnicalFault_Exception {
		try {
			return SL.getInstance().getTaskMasterDataService().unspecifyPriority(task);
		} catch (final BusinessException businessException) {
			final BusinessFault businessFault = FACTORY.createBusinessFault();
			businessFault.setMessage(businessException.getMessage());
			businessFault.setCode(businessException.getCode());
			throw new BusinessFault_Exception(BUSSINESSFAULT_DEFAULT_MESSAGE, businessFault);
		} catch (final TechnicalException technicalException) {
			final TechnicalFault technicalFault = FACTORY.createTechnicalFault();
			technicalFault.setMessage(technicalException.getMessage());
			technicalFault.setCode(technicalException.getCode());
			throw new TechnicalFault_Exception(TECHNICALFAULT_DEFAULT_MESSAGE, technicalFault);
		}
	}

	@Override
	public Task updateExpectedEndDateTask(final Task task) throws BusinessFault_Exception, TechnicalFault_Exception {
		try {
			return SL.getInstance().getTaskMasterDataService().updateExpectedEndDate(task);
		} catch (final BusinessException businessException) {
			final BusinessFault businessFault = FACTORY.createBusinessFault();
			businessFault.setMessage(businessException.getMessage());
			businessFault.setCode(businessException.getCode());
			throw new BusinessFault_Exception(BUSSINESSFAULT_DEFAULT_MESSAGE, businessFault);
		} catch (final TechnicalException technicalException) {
			final TechnicalFault technicalFault = FACTORY.createTechnicalFault();
			technicalFault.setMessage(technicalException.getMessage());
			technicalFault.setCode(technicalException.getCode());
			throw new TechnicalFault_Exception(TECHNICALFAULT_DEFAULT_MESSAGE, technicalFault);
		}
	}

	@Override
	public Task updateExpectedStartDateTask(final Task task) throws BusinessFault_Exception, TechnicalFault_Exception {
		try {
			return SL.getInstance().getTaskMasterDataService().updateExpectedStartDate(task);
		} catch (final BusinessException businessException) {
			final BusinessFault businessFault = FACTORY.createBusinessFault();
			businessFault.setMessage(businessException.getMessage());
			businessFault.setCode(businessException.getCode());
			throw new BusinessFault_Exception(BUSSINESSFAULT_DEFAULT_MESSAGE, businessFault);
		} catch (final TechnicalException technicalException) {
			final TechnicalFault technicalFault = FACTORY.createTechnicalFault();
			technicalFault.setMessage(technicalException.getMessage());
			technicalFault.setCode(technicalException.getCode());
			throw new TechnicalFault_Exception(TECHNICALFAULT_DEFAULT_MESSAGE, technicalFault);
		}
	}

	@Override
	public Task updateTaskCategory(final Task task) throws BusinessFault_Exception, TechnicalFault_Exception {
		try {
			return SL.getInstance().getTaskMasterDataService().updateTaskCategory(task);
		} catch (final BusinessException businessException) {
			final BusinessFault businessFault = FACTORY.createBusinessFault();
			businessFault.setMessage(businessException.getMessage());
			businessFault.setCode(businessException.getCode());
			throw new BusinessFault_Exception(BUSSINESSFAULT_DEFAULT_MESSAGE, businessFault);
		} catch (final TechnicalException technicalException) {
			final TechnicalFault technicalFault = FACTORY.createTechnicalFault();
			technicalFault.setMessage(technicalException.getMessage());
			technicalFault.setCode(technicalException.getCode());
			throw new TechnicalFault_Exception(TECHNICALFAULT_DEFAULT_MESSAGE, technicalFault);
		}
	}

	@Override
	public Task updateTaskDescription(final Task task) throws BusinessFault_Exception, TechnicalFault_Exception {
		try {
			return SL.getInstance().getTaskMasterDataService().updateTaskDescription(task);
		} catch (final BusinessException businessException) {
			final BusinessFault businessFault = FACTORY.createBusinessFault();
			businessFault.setMessage(businessException.getMessage());
			businessFault.setCode(businessException.getCode());
			throw new BusinessFault_Exception(BUSSINESSFAULT_DEFAULT_MESSAGE, businessFault);
		} catch (final TechnicalException technicalException) {
			final TechnicalFault technicalFault = FACTORY.createTechnicalFault();
			technicalFault.setMessage(technicalException.getMessage());
			technicalFault.setCode(technicalException.getCode());
			throw new TechnicalFault_Exception(TECHNICALFAULT_DEFAULT_MESSAGE, technicalFault);
		}
	}

	@Override
	public Task updateTaskName(final Task task) throws BusinessFault_Exception, TechnicalFault_Exception {
		try {
			return SL.getInstance().getTaskMasterDataService().updateTaskName(task);
		} catch (final BusinessException businessException) {
			final BusinessFault businessFault = FACTORY.createBusinessFault();
			businessFault.setMessage(businessException.getMessage());
			businessFault.setCode(businessException.getCode());
			throw new BusinessFault_Exception(BUSSINESSFAULT_DEFAULT_MESSAGE, businessFault);
		} catch (final TechnicalException technicalException) {
			final TechnicalFault technicalFault = FACTORY.createTechnicalFault();
			technicalFault.setMessage(technicalException.getMessage());
			technicalFault.setCode(technicalException.getCode());
			throw new TechnicalFault_Exception(TECHNICALFAULT_DEFAULT_MESSAGE, technicalFault);
		}
	}

}
